package com.lichuang.dedao.city.mapper;

import com.lichuang.dedao.city.entity.Comment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lichuang.dedao.city.entity.Reply;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author wp
 * @since 2019-07-13
 */
public interface CommentMapper extends BaseMapper<Comment> {


    /**
     * 查询该笔记一级评论
     * @param notrId
     * @return
     */
    @Select("select * from comment where notr_id = #{notrId} and comment_parent_id = -1")
    List<Comment> selByNoteId(Integer notrId);


    /**
     * 查询该笔记下一级的子级评论
     * @param notr_id
     * @return
     */
    @Select("select * from comment where notr_id = #{notr_id} and comment_parent_id != -1")
    List<Comment> selByparentId(Integer notr_id);


    /**
     * 评论 评论笔记，parent_id为-1。评论其他评论，parent_id为父级评论id
     * @param comment
     * @return
     */
    @Insert("insert into comment(notr_id, comment_content, comment_parent_id, comment_user_id, comment_time) VALUES (#{notr_id},#{comment_content},#{comment_parent_id},#{comment_user_id},#{comment_time})")
    int insNoteComment(Comment comment);






//    @Select("")
//    List<Comment> selById(Integer parentId);

}
